home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / ada / changesn.ada < prev    next >
Text File  |  1988-03-25  |  2KB  |  50 lines

  1. -- CHANGESN.ADA   Ver. 1.00   25-MAR-1988
  2. -- Copyright 1988 John J. Herro
  3. -- Software Innovations Technology
  4. -- 1083 Mandarin Drive NE, Palm Bay, FL 32905-4706   (407)951-0233
  5. --
  6. -- Used to change the serial number in ADA-TUTR.DAT after registering.  When
  7. -- compiling this program on any computer other than a PC running Artek Ada
  8. -- (tm, Artek Corp.), compile NON-PC.ADA or VAX.ADA first.
  9. --
  10. with CON_IO, DIRECT_IO; use CON_IO;
  11.    -- The package CON_IO (console I/O) comes with Artek Ada.  CON_IO contains
  12.    -- PUT, PUT_LINE, and NEW_LINE, similar to TEXT_IO.  It also contains GET to
  13.    -- get a string (with editing capability).
  14. procedure CHANGESN is
  15.    subtype BLOCK_SUBTYPE is STRING(1 .. 64);
  16.    package RANDOM_IO is new DIRECT_IO(BLOCK_SUBTYPE); use RANDOM_IO;
  17.    DATA_FILE  : RANDOM_IO.FILE_TYPE;
  18.    BLOCK      : BLOCK_SUBTYPE;                -- Block read from the data file.
  19.    BLOCK_NUM  : RANDOM_IO.COUNT := 58;          -- Number of the current block.
  20.    PLACE      : INTEGER;                     -- Index to search for "Serial #".
  21.    FOUND      : BOOLEAN := FALSE;             -- True when "Serial #" is found.
  22.    SERIAL_NUM : STRING(1 .. 5);                 -- The serial number, in ASCII.
  23.    LEGAL_NOTE : constant STRING(1 .. 30) := " Copyright 1988 John J. Herro ";
  24.                          -- LEGAL_NOTE isn't used by the program, but it causes
  25.                          -- the compiler to place this string in the .EXE file.
  26. begin
  27.    RANDOM_IO.OPEN(DATA_FILE, MODE => INOUT_FILE, NAME => "ADA-TUTR.DAT");
  28.    while not FOUND loop
  29.       BLOCK_NUM := BLOCK_NUM + 1;
  30.       READ(FILE => DATA_FILE, ITEM => BLOCK, FROM => BLOCK_NUM);
  31.       PLACE := 0;
  32.       while not FOUND and PLACE <= 50 loop
  33.          PLACE := PLACE + 1;
  34.          FOUND := BLOCK(PLACE .. PLACE + 7) = "Serial #";
  35.       end loop;
  36.    end loop;
  37.    SERIAL_NUM := BLOCK(PLACE + 10 .. PLACE + 14);
  38.    PUT_LINE("Old serial number is " & SERIAL_NUM & ".");
  39.    PUT("New serial number:   ");
  40.    GET(SERIAL_NUM);
  41.    NEW_LINE;
  42.    BLOCK(PLACE + 10 .. PLACE + 14) := SERIAL_NUM;
  43.    WRITE(FILE => DATA_FILE, ITEM => BLOCK, TO => BLOCK_NUM);
  44.    CLOSE(DATA_FILE);
  45.    PUT_LINE("Serial number changed.");
  46. exception
  47.    when RANDOM_IO.NAME_ERROR =>
  48.       PUT_LINE("I'm sorry.  The file ADA-TUTR.DAT seems to be missing.");
  49. end CHANGESN;
  50.